﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace SmartMD.DataModel.Entity
{
    public class ContainerModelEntity : BusinessEntity
    {
        private ModelStyle _modelType;
        private byte[]  _styleFile;
        private DateTime _createDate;

        public ModelStyle ModelType
        {
            get { return _modelType; }
            set
            {
                _modelType = value;
                OnPropertyChanged(() => ModelType);
            }
        }
        [DataMember(Name = "Style", EmitDefaultValue = false)]
        public byte[] StyleFile
        {
            get { return _styleFile; }
            set {
                _styleFile = value;
                OnPropertyChanged(() => StyleFile);
            }
        }

        [DataMember(Name = "CreateDate", EmitDefaultValue = false)]
        public DateTime CreateDate
        {
            get { return _createDate; }
            set { 
                _createDate = value;
                OnPropertyChanged(() => CreateDate);
            }
        }

        public override void setValue(string key, Object value)
        {
            if (value is System.DBNull)
                return;
            switch (key.ToLower())
            {
                case "id":
                    this.Id = (string)value;
                    break;
                case "name":
                    this.Name = (string)value;
                    break;
                case "stylefile":
                    this.StyleFile = (byte[])value;
                    break;
                case "createdate":
                    this.CreateDate = (DateTime)value;
                    break;

                default:
                    break;
            }
        }
        public static ModelStyle GetStyle(string value)
        {
            ModelStyle style =  ModelStyle.VerticalFridge;
            switch (value)
            {
                case "HorizontalFridge":
                    style = ModelStyle.HorizontalFridge;
                    break;
                case "VerticalFridge":
                    style = ModelStyle.VerticalFridge;
                    break;
                case "LiquidNitrogenJar":
                    style = ModelStyle.LiquidNitrogenJar;
                    break;
            }
            return style;
        }
    }
}
